using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;
using Buddy.Coroutines;

namespace Triton.Bot.Profiles
{
	[Serializable]
	public abstract class ProfileElement : IAuthored
	{
		[XmlIgnore]
		public ProfileElement ReferenceElement { get; set; }

		[XmlIgnore]
		public string ElementName => GetType().GetCustomAttribute<ProfileElementNameAttribute>().ElementName;

		[XmlAttribute("RefName")]
		public string ReferenceName { get; set; }

		[XmlAttribute("RefTag")]
		public string ReferenceTag { get; set; }

		[XmlIgnore]
		public abstract string Name { get; }

		[XmlIgnore]
		public abstract string Author { get; }

		[XmlIgnore]
		public abstract string Version { get; }

		[XmlAttribute]
		public abstract string Description { get; }

		[XmlIgnore]
		public virtual bool IsFinished => false;

		public virtual void LoadElement(List<ProfileElement> currentList, XElement element)
		{
		}

		public virtual void OnRegistered()
		{
		}

		public virtual void OnUnregistered()
		{
		}

		public virtual void Pulse()
		{
		}

		public virtual Task ProfileTagLogic()
		{
			return Coroutine.Yield();
		}

		public virtual void Reset()
		{
		}
	}
}
